package controller;

import dao.GoodDao;
import dao.WarehouseDao;
import dao.impl.GoodDaoImpl;
import dao.impl.WarehouseImpl;
import po.Good;
import po.Warehouse;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class PutStorage extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        System.out.println("HIHI");
        String goodId = req.getParameter("goodId");
        String warehouseId = req.getParameter("warehouseId");

//        System.out.println(goodId+" "+warehouseId);
        GoodDao dao = new GoodDaoImpl();
        Good good = dao.getGood(goodId);

        Warehouse warehouse=new Warehouse();
        warehouse.setWarehouseId(warehouseId);
        warehouse.setGoodId(goodId);
        warehouse.setGoodName(good.getGoodName());
        warehouse.setType(good.getType());
        warehouse.setCount(good.getCount());
        warehouse.setCost(good.getCost());

        WarehouseDao warehouseDao=new WarehouseImpl();
        warehouseDao.addWarehouse(warehouse);

    }
}
